package com.hmkx.service.impl;

import com.hmkx.config.TargetDataSource;
import com.hmkx.mapper.ArticlesMapper;
import com.hmkx.model.Articles;
import com.hmkx.model.ArticlesWithBLOBs;
import com.hmkx.service.ArticleService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Map;

@Service
public class ArticleServiceImpl  implements ArticleService {


    Logger log = LoggerFactory.getLogger(ArticleServiceImpl.class);

    @Resource
    private ArticlesMapper articlesMapper;


    @Override
    public Articles getArticleById(int id) {
        Articles articles = articlesMapper.selectByPrimaryKey(501112);
        log.info(articles.getTitle());
        return articles;
    }

    @Override
    @TargetDataSource(name="ucenter")
    public int updateByPrimaryKey(int id) {
        ArticlesWithBLOBs art = new ArticlesWithBLOBs();
        art.setId(501112);
        art.setTitle("测试");
        int res = articlesMapper.updateByPrimaryKeySelective(art);
        return res;
    }

}
